Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




clear( ) FUNCTION


The 'clear( )' Function can be used to remove all the elements from the Set.


Example :


x = {"Mohan", "Kriti", "Salim"}
x.clear()
print(x) 


Output :



  set( )

So, in the above code we have created a 'Set' and initialised to the variable 'x'.


x = ["Mohan", "Kriti", "Salim"]

java_Collections

Next, we have used the 'clear( )' function that removes all the elements from the Set making the Set empty.


x.clear( )

And we get an empty Set as output,


set( )

The output 'set( )' means, it represents an empty Set.